bcc7721d12393482da137cf9e58cf2d42a534d1c,oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/SegmentWriter.java,SegmentWriter,writeNode,#NodeState#,633
Before Change
public RecordId writeNode(NodeState state) {
RecordId nodeId = SegmentNodeState.getRecordIdIfAvailable(state);
if (nodeId != null) {
return nodeId;
}
SegmentNodeState before = null;
ModifiedNodeState after = null;
if (state instanceof ModifiedNodeState) {
after = ModifiedNodeState.collapse((ModifiedNodeState) state);
NodeState base = after.getBaseState();
if (base instanceof SegmentNodeState) {
before = (SegmentNodeState) base;
}
}
Template template = new Template(state);
List<RecordId> ids = Lists.newArrayList();
ids.add(writeTemplate(template));
if (template.hasManyChildNodes()) {
MapRecord base;
final Map<String, RecordId> childNodes = Maps.newHashMap();
if (before != null
&& before.getChildNodeCount() > 1
&& after.getChildNodeCount() > 1) {
base = before.getChildNodeMap();
after.compareAgainstBaseState(before, new DefaultNodeStateDiff() {
@Override
public void childNodeAdded(String name, NodeState after) {
childNodes.put(name, writeNode(after));
}
@Override
public void childNodeChanged(
String name, NodeState before, NodeState after) {
childNodes.put(name, writeNode(after));
}
@Override
public void childNodeDeleted(String name, NodeState before) {
childNodes.put(name, null);
}
});
} else {
base = null;
for (ChildNodeEntry entry : state.getChildNodeEntries()) {
childNodes.put(entry.getName(), writeNode(entry.getNodeState()));
}
}
ids.add(writeMap(base, childNodes).getRecordId());
} else if (!template.hasNoChildNodes()) {
ids.add(writeNode(state.getChildNode(template.getChildName())));
}
for (PropertyTemplate property : template.getPropertyTemplates()) {
After Change
}
ids.add(writeMap(base, childNodes).getRecordId());
} else if (!template.hasNoChildNodes()) {
ids.add(writeNode(state.getChildNode(template.getChildName())).getRecordId());
}
for (PropertyTemplate property : template.getPropertyTemplates()) {